﻿using FacadePattern.EncryptionModuleSample;
using System;
using System.Configuration;
using System.Reflection;

namespace FacadePattern
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello FacadePattern!");

            {
                //demo 举例
                Facade facade = new Facade();
                facade.Method();
            }

            {
                // 应用案例，加密模块
                EncryptFacade ef = new EncryptFacade(); //针对具体外观类编程
                ef.FileEncrypt("src.txt", "des.txt");
            }

            {
                AbstractEncryptFacade ef; //针对抽象建造者编程
                //读取配置文件
                string facadeString = ConfigurationManager.AppSettings["facade"];
                //反射生成对象
                ef = (AbstractEncryptFacade)Assembly.Load("FacadePattern").CreateInstance(facadeString);
                ef.FileEncrypt("src.txt", "des.txt");
            }

            Console.ReadKey();
        }

    }
}
